﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace BadHabit.Factory.Controls {
    /// <summary>
    /// Interaction logic for ProjectSizeIndicator.xaml
    /// </summary>
    public partial class ProjectSizeIndicator : UserControl {

        public ProjectSizeIndicator() {
            InitializeComponent();
        }

        public ImageSource IndicadorIcon { get; set; }
        public ImageSource IndicadorOffIcon { get; set; }

        private int rank = 0;
        public int Rank {
            set {
                rank = value;
                if(rank<0)
                    rank = 0;
                if (rank > 4)
                    rank = 4;

                panel.Children.Clear();

                if (rank == 0) {
                    AddRankImage();
                    AddOffImage();
                    AddOffImage();
                    indicatorRankNameTextBlock.Text = global::BadHabit.Factory.Windows.Properties.Resources._Small_;
                }
                if (rank == 1 || rank == 2) {
                    AddRankImage();
                    AddRankImage();                    
                    AddOffImage();
                    indicatorRankNameTextBlock.Text = global::BadHabit.Factory.Windows.Properties.Resources._Medium_;
                }                
                if (rank == 3 || rank == 4) {
                    AddRankImage();
                    AddRankImage();
                    AddRankImage();
                    indicatorRankNameTextBlock.Text = global::BadHabit.Factory.Windows.Properties.Resources._Big_;
                }
            }
        }

        public string IndicatorName {
            set {
                indicatorNameTextBlock.Text = value;
            }
        }

        private void AddRankImage() {
            Image img = new Image();
            img.Source = IndicadorIcon;
            img.Width = 16;
            img.Height = 16;
            img.Margin = new Thickness(2);
            panel.Children.Add(img);            
            
        }
        private void AddOffImage() {
            Image img = new Image();
            img.Source = IndicadorOffIcon;
            img.Width = 16;
            img.Height = 16;
            img.Margin = new Thickness(2);
            panel.Children.Add(img);
        }
    }
}
